﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;

namespace MN.Framework.UI.Win
{
    public class TzPhotoForm : RadForm
    {
        PictureBox photoControl;
        RadButton btnChangePhoto;
        PictureBox Sender;
        public TzPhotoForm(object sender)
        {
            photoControl = new PictureBox();
            Sender = (PictureBox)sender;
            photoControl.Image = Sender.Image;
            photoControl.Dock = DockStyle.Fill;
            this.Controls.Add(photoControl);

            btnChangePhoto = new RadButton();
            btnChangePhoto.Text = "تغییر عکس";
            btnChangePhoto.Dock = DockStyle.Bottom;
            btnChangePhoto.Click += btnChangePhoto_Click;
           
            this.Controls.Add(btnChangePhoto);
        }
        void btnChangePhoto_Click(object sender, EventArgs e)
        {
            // open file dialog 
            OpenFileDialog open = new OpenFileDialog();
            // image filters
            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
            if (open.ShowDialog() == DialogResult.OK)
            {
                // display image in picture box
                photoControl.Image = new Bitmap(open.FileName);
                Sender.Image = photoControl.Image;
                // image file path
                //textBox1.Text = open.FileName;
            }
        }
    }
}
